package com.example.forum.interceptor;

import com.example.forum.entity.User;

//登录之后的用户信息
public class UserContext {
    //    private static User current;不是线程安全的
    private static final ThreadLocal<User>current =new ThreadLocal<>();
    public static void setUser(User user){
//        current=user;
        current.set(user);
    }
    public  static User getUser(){
//        return current;
        return current.get();
    }
    public  static User getId(){
//        return current;
        return current.get();
    }
}